import { createVNode, render } from "vue";
import XtxConfirm from './xtx-confirm.vue'

const div = document.createElement('div')
div.setAttribute('class', 'xtx-confirm-container')
document.body.appendChild(div)

export default ({ text, tittle }) => {
    return new Promise((resolve, reject) => {
        const submitCallback = () => {
            resolve()
            render(null, div)
        }
        const cancelCallback = () => {
            reject()
            render(null,div)
        }

        const vnode = createVNode(XtxConfirm,{text,tittle,submitCallback,cancelCallback})
        render(vnode,div)
    })
}